package com.madoka.base.utils.validation.constraints;


import com.madoka.base.utils.validation.validators.DateRangeValidator;

import javax.validation.Constraint;
import javax.validation.Payload;
import javax.validation.ReportAsSingleViolation;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * The annotated element has to be in the appropriate range. Apply on date values or string
 * representation of the date value.
 *
 * @author Chen Yan Yi
 */
@Constraint(validatedBy = DateRangeValidator.class)
@Target({TYPE, ANNOTATION_TYPE})
@Retention(RUNTIME)
@Documented
@ReportAsSingleViolation
public @interface DateRange {

    String message() default "{org.hibernate.validator.constraints.DateRange.message}";
    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};

    /**
     * @return start
     */
    String begin();

    /**
     * @return end
     */
    String end();

    /**
     * @return place
     */
    String target();


    /**
     * @return including current
     */
    boolean current() default false;

    /**
     * Defines several <code>@DateRange</code> annotations on the same element
     *
     * @see DateRange
     */
    @Target({TYPE, ANNOTATION_TYPE})
    @Retention(RUNTIME)
    @Documented
    @interface List {
        DateRange[] value();
    }
}
